package com.sq.partner.manager.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.sq.partner.manager.dao.ActivationCardSheetDao;
import com.sq.partner.manager.mybatis.model.ActirationCardMinMaxDto;
import com.sq.partner.manager.mybatis.model.ActirationCardReceiveDto;
import com.sq.partner.manager.mybatis.model.ActivationCardSheet;
import com.sq.partner.manager.mybatis.model.DeptDto;
import com.sq.partner.manager.util.Page;

@Repository
public class ActivationCardSheetDaoImpl extends BaseDaoImpl implements ActivationCardSheetDao {
	@Override
	public boolean insert(List<ActivationCardSheet> t) throws Exception{
//		return this.add("insertcardSheetList", t);
		this.batchInsert("insertcardSheetOne", t);
		return true;
	}
	@Override
	public boolean delete(ActivationCardSheet t) throws Exception{
		return this.delete("deleteCardSheet",t);
	}
	@Override
	public boolean update(ActivationCardSheet t) throws Exception{
		return this.update("updateCardSheet",t);
	}
	@Override
	public ActivationCardSheet query(ActivationCardSheet t) throws Exception{
		return (ActivationCardSheet)this.query("queryCardSheet",t);
	}
	@SuppressWarnings("unchecked")
	@Override
	public Page<ActivationCardSheet> queryPage(Page<ActivationCardSheet> page) throws Exception{
		page.setTotal((Integer)this.query("querycardSheetCount", page.getMap()));
		page.setData((List<ActivationCardSheet>)this.queryList("querycardSheetPage", page.getMap()));
		return page;
	}
	@SuppressWarnings("unchecked")
	@Override
	public  List<ActivationCardSheet> queryList(Map<String, Object> map) throws Exception{
		return (List<ActivationCardSheet>)this.queryList("querycardSheetList", map);
	}
	@Override
	public synchronized String getMaxNo(ActivationCardSheet info) throws Exception{
		return (String)this.query("querycardSheetMax", info);
	}
	@SuppressWarnings("unchecked")
	@Override
	public Page<String> getLzNoPage(Page<String> page) throws Exception{
		page.setData((List<String>)this.queryList("querylzPage", page.getMap()));
		page.setTotal((Integer) this.query("querylzPageCount", page.getMap()));
		return page;
	}
	@SuppressWarnings("unchecked")
	@Override
	public Page<ActirationCardMinMaxDto> getMinMaxPage(Page<ActirationCardMinMaxDto> page) throws Exception{
		page.setData((List<ActirationCardMinMaxDto>)this.queryList("queryGroup", page.getMap()));
		page.setTotal((Integer)this.query("queryGroupCount", page.getMap()));
		return page;
	}
	@Override
	public ActirationCardMinMaxDto getMinMax(Map<String, Object> map) throws Exception{
		return (ActirationCardMinMaxDto) this.query("queryGroup", map);
	}
	@SuppressWarnings("unchecked")
	@Override
	public List<String> getLzNoList(Map<String, Object> map) throws Exception{
		return (List<String>)this.queryList("querylzList", map);
	}
	@SuppressWarnings("unchecked")
	@Override
	public Page<ActirationCardReceiveDto> getReceivePage(Page<ActirationCardReceiveDto> page) throws Exception{
		page.setData((List<ActirationCardReceiveDto>)this.queryList("queryjsgroup", page.getMap()));
		page.setTotal((Integer)this.query("queryjsgroupCount", page.getMap()));
		return page;
	}
	@SuppressWarnings("unchecked")
	@Override
	public Page<String>getReceiveNoList(Page<String> page) throws Exception{
		page.setData((List<String>)this.queryList("queryjsList", page.getMap()));
		page.setTotal((Integer)this.query("queryjsListCount", page.getMap()));
		return page;
	}
	@SuppressWarnings("unchecked")
	@Override
	public List<DeptDto> getComDown(String userCom) throws Exception{
		return (List<DeptDto>)this.queryList("query_comdown", userCom);
	}
	@SuppressWarnings("unchecked")
	@Override
	public List<DeptDto> getComUp(String userCom) throws Exception{
		return (List<DeptDto>)this.queryList("query_comup", userCom);
	}
	@Override
	public Integer getMaxNum(HashMap<String, Object> paramMap) throws Exception{
		return (Integer)this.query("queryMaxNum", paramMap);
	}
	public Integer getjsMaxNum(HashMap<String, Object> paramMap) throws Exception{
		return (Integer)this.query("queryjsMaxNum", paramMap);
	}
	@Override
	public boolean delayOne(HashMap<String,Object> map) throws Exception{
		return this.update("updateDelayOne", map);
	}
	@Override
	public boolean delayByStartAndEnd(HashMap<String,Object> map) throws Exception{
		return this.update("updateDelay",map);
	}
	@Override
	public Integer queryDelayCount(HashMap<String,Object> map) throws Exception{
		return (Integer)this.query("queryDelayCount", map);
	}
	@SuppressWarnings("unchecked")
	/**
	 * 查询本级机构
	 */
	@Override
	public List<DeptDto> getComAndDown(String userCom) throws Exception{
		return (List<DeptDto>)this.queryList("query_comAnddown", userCom);
	}
	@Override
	public boolean updateDoCircul(Map<String, Object> map)throws Exception{
		return this.update("updateDoCircul", map);
	}
	@Override
	public boolean updateDoReceive(HashMap<String, Object> map)throws Exception{
		return this.update("updateDoReceive",map);
	}
	@Override
	public boolean updateStatusForTimerTask(HashMap<String,Object> map) throws Exception {
		return this.update("updateStatusForTimerTask",map);
	}
}
